<template>
	<view class="button-box">
		<view class="mx-buy-button">
			
			<view class="price-bar" @click="show = true">
				<!-- <image class="img-bag" src="/static/imgs/coupon.png"></image> -->
				<text v-show="total > 0" >￥{{total}}</text>
				<text >￥{{coupon_price}}</text>
			</view>
			
			<view class="buy-btn" @tap="onTap">
				<image src="/static/imgs/buy-btn.png"></image>
				<view class="btn-text">
					<view class="text-title">{{title}}</view>
					<image class="btn-img" src="/static/imgs/buy-btn-arrow.png"></image>
				</view>
			</view>
		</view>

	</view>

</template>

<script>
	export default {
		name: "MxBuyButton",
		props: {
			title: {
				type: String,
				default: '立即购买'
			},

			total: {
				type: String,
				default: '0'
			},
			
			coupon_price: {
				type: String,
				default: '0'
			},
		},
		data() {
			return {
				show: false,
			};
		},
		methods: {
			onTap() {
				this.$emit('buy', 0)
			},

			use(coupon_id) {
				this.$emit('buy', coupon_id)
			},

		}
	}
</script>

<style scoped lang="scss">
	@import '@/common/scss/common.scss';

	.coupon_list {
		margin-left: 2%;
		height: 400rpx;
	}
	
	.button-box{width: 100%;padding: 0 25rpx}

	.mx-buy-button {
		width: 100%;
		min-width: 330px;
		height: 104rpx;
		display: flex;
		align-items: center;
		position: relative;
		

		.price-bar {
			background-color: #fff;
			box-sizing: border-box;
			padding: 20rpx 16rpx;
			width: 100%;
			box-shadow: 0 0 2px 0 rgba($color: #000000, $alpha: .16);
			border-radius: 5px;
			display: flex;
			align-items: center;

			.img-bag {
				width: 44rpx;
				height: 50rpx;
				margin-right: 48rpx;
			}

			&>text:nth-child(1) {
				font-size: 16px;
				font-weight: bold;
				color: $color-primary;
				margin-right: 60rpx;
				text-decoration: line-through;
			}

			&>text:nth-child(2) {
				font-size: 18px;
				font-weight: bold;
				color: $color-amount;
			}
		}

		.buy-btn {
			position: absolute;
			top: 0;
			right: 0;

			&>image {
				width: 248rpx;
				height: 104rpx;
			}

			.btn-text {
				display: inline-flex;
				justify-content: center;
				align-items: center;
				width: 220rpx;
				height: 104rpx;
				position: absolute;
				top: 0;
				right: 0;

				.btn-img {
					margin-left: 12rpx;
					width: 12rpx;
					height: 24rpx;
					position: relative;
					top: 1px;
				}

				.text-title {
					color: #fff;
					font-size: 16px;
					line-height: 16px;
					display: flex;
					align-items: center;
				}


			}
		}
	}
</style>